import { Component, OnInit } from '@angular/core';
import { EntryModelService } from "./entry-model.service";

@Component({
  selector: 'app-entry-model',
  templateUrl: './entry-model.component.html',
  styleUrls: ['./entry-model.component.scss'],
  providers: [EntryModelService]
})
export class EntryModelComponent implements OnInit {
  //服务条目模板参数
  public serviceEntryModel: any;
  constructor(
    public entryModelService: EntryModelService
  ) { }

  ngOnInit() {
    this.getServiceEntryModel();
    window['$'](".modal-detail").modal('show');
  }
  //获取模板参数接口
  getServiceEntryModel() {
    this.entryModelService.getServiceEntryModel().subscribe(data => {
      if (data) {
        // console.log(data);
        this.serviceEntryModel = data;
      }
    })
  }
  //更新模板参数接口
  updateServiceEntryModel() {
    let that = this;
    window["swal"]({
      title: "注意",
      text: "是否确定修改模板参数",
      type: "warning",
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      showCancelButton: true,
      closeOnConfirm: false,
      closeOnCancel: true,
      showLoaderOnConfirm: true
    },
      function (isConfirm) {
        if (isConfirm) {
          that.entryModelService.updateServiceEntryModel(that.serviceEntryModel).subscribe(data => {
            if (data) {
              window['swal']("提示", "修改成功!", "success")
              that.getServiceEntryModel()
            }
          })
        }
      })
  }
}
